/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SnpDbEntities;

import java.io.Serializable;
import java.util.Date;


/**
 *
 * @author Łukasz 'byku' Guzik
 */
public class Snippet implements Serializable
{
    private static class MaxLengths
    {
	private static final int MAX_NAME_LENGTH = 100;
	private static final int MAX_DESC_LENGTH = 200;
	private static final int MAX_DATA_LENGTH = 40000;
    }
    private int id;
    private String name;
    private String desc;
    private Date lastModified;
    private int ownerId;
    private int categoryId;
    private String data;
    private CodeTypes codeType;

    public int getId()
    {
	return id;
    }

    public void setId(int id)
    {
	this.id = id;
    }

    public String getName()
    {
	return name;
    }

    public void setName(String name)
    {
	if(name != null && name.length() > MaxLengths.MAX_NAME_LENGTH)
	{
	    throw new IllegalArgumentException("Max name length: " + MaxLengths.MAX_NAME_LENGTH);
	}
	this.name = name;
    }

    public String getDesc()
    {
	return desc;
    }

    public void setDesc(String desc)
    {
	if(desc != null && desc.length() > MaxLengths.MAX_DESC_LENGTH)
	{
	    throw new IllegalArgumentException("Max description length: " + MaxLengths.MAX_DESC_LENGTH);
	}
	this.desc = desc;
    }

    public Date getLastModified()
    {
	return lastModified;
    }

    public void setLastModified(Date lastModified)
    {
	this.lastModified = lastModified;
    }

    public int getOwnerId()
    {
	return ownerId;
    }

    public void setOwnerId(int ownerId)
    {
	this.ownerId = ownerId;
    }

    public int getCategoryId()
    {
	return categoryId;
    }

    public void setCategoryId(int categoryId)
    {
	this.categoryId = categoryId;
    }

    public String getData()
    {
	return data;
    }

    public void setData(String data)
    {
	if(data != null && data.length() > MaxLengths.MAX_DATA_LENGTH)
	{
	    throw new IllegalArgumentException("Max snippet length: " + MaxLengths.MAX_DATA_LENGTH);
	}
	this.data = data;
    }

    public CodeTypes getCodeType()
    {
	return codeType;
    }

    public void setCodeType(CodeTypes codeType)
    {
	this.codeType = codeType;
    }

    @Override
    public String toString()
    {
	return getName();
    }
}
